using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Common;

namespace SExperiment.ExperimentResult
{
	[Serializable]
	public class MeltingTargetResult : TargetResult
	{
		[NonSerialized]
		private Curve _RawMeltingCurve = new Curve();

		[NonSerialized]
		private Curve _PeakCurve = new Curve();

		[NonSerialized]
		private Curve _XCurve = new Curve();

		[NonSerialized]
		private Curve _NormalizationPeakCurve = new Curve();

		[NonSerialized]
		private List<MeltPeak> _PeakValues = new List<MeltPeak>();

		[NonSerialized]
		private double _QualityFactor = double.NaN;

		public Curve RawMeltingCurve
		{
			get
			{
				return _RawMeltingCurve;
			}
			set
			{
				if (_RawMeltingCurve != value)
				{
					_RawMeltingCurve = value;
					OnPropertyChanged("RawMeltingCurve");
				}
			}
		}

		public Curve MiddleCurve { get; set; }

		public Curve PeakCurve
		{
			get
			{
				return _PeakCurve;
			}
			set
			{
				if (_PeakCurve != value)
				{
					_PeakCurve = value;
					OnPropertyChanged("PeakCurve");
				}
			}
		}

		public Curve XCurve
		{
			get
			{
				return _XCurve;
			}
			set
			{
				if (_XCurve != value)
				{
					_XCurve = value;
					OnPropertyChanged("XCurve");
				}
			}
		}

		public Curve NormalizationPeakCurve
		{
			get
			{
				return _NormalizationPeakCurve;
			}
			set
			{
				if (_NormalizationPeakCurve != value)
				{
					_NormalizationPeakCurve = value;
					OnPropertyChanged("NormalizationPeakCurve");
				}
			}
		}

		public List<MeltPeak> PeakValues
		{
			get
			{
				return _PeakValues;
			}
			set
			{
				if (_PeakValues != value)
				{
					_PeakValues = value;
					OnPropertyChanged("PeakValues");
				}
			}
		}

		public double QualityFactor
		{
			get
			{
				return _QualityFactor;
			}
			set
			{
				if (_QualityFactor != value)
				{
					_QualityFactor = value;
					OnPropertyChanged("QualityFactor");
				}
			}
		}

		[OnDeserialized]
		private void OnDeserialized(StreamingContext context)
		{
			if (_RawMeltingCurve == null)
			{
				_RawMeltingCurve = new Curve();
			}
			if (_PeakCurve == null)
			{
				_PeakCurve = new Curve();
			}
			if (_PeakValues == null)
			{
				_PeakValues = new List<MeltPeak>();
			}
			if (_XCurve == null)
			{
				_XCurve = new Curve();
			}
		}
	}
}
